Attribute VB_Name = "UTILITY"
Option Explicit

Global DELIM_STD     As String
Global DELIM_SYS     As String
Global DELIM_ALT     As String
Global Const ACODE_DELIM_STD = 94 'Used to prevent users typing in the delimiter
Global DELIM_FTA     As String 'This is a Free Text Alternate character. It is used to prevent DELIM_STD being sent to the database inside a field (typically free text fields).
Global DELIM_CRA     As String 'This is a Carriage Return Alternate character. It is used to prevent "|" being sent to the database when it does not represent vbCRLF (typically free text fields).

Public Const MF_STRING = &H0&

Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Declare Function GetTickCount Lib "kernel32" () As Long
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function PostThreadMessage Lib "user32" Alias "PostThreadMessageA" (ByVal idThread As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function ReadComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bReDraw As Boolean) As Long
Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lpFileName As String) As Long
Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As Size) As Long
Declare Function SetWindowWord Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
Declare Function EqualRect Lib "user32" (lpRect1 As RECT, lpRect2 As RECT) As Long
Declare Function IsRectEmpty Lib "user32" (lpRect As RECT) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpBytesFree As Long, lpBytesAvail As Long, lpTotalFree As Long) As Long
Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
Declare Function CreatePopupMenu Lib "user32" () As Long
Declare Function LoadMenu Lib "user32" Alias "LoadMenuA" (ByVal hInstance As Long, ByVal lpString As String) As Long
Declare Function SetMenu Lib "user32" (ByVal hWnd As Long, ByVal hMenu As Long) As Long
Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

'Registry
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal HKEY As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
'Locale
Declare Function GetSystemDefaultLangID Lib "kernel32" () As Integer
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, _
                                                        ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
                                                        ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
                                                        ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
                                                        lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Type Size
  cx As Long
  cy As Long
End Type

Type POINTAPI
        X As Long
        Y As Long
End Type

Type RECT
  Left     As Long
  Top      As Long
  Right    As Long
  Bottom   As Long
End Type
'API Rountine Declarations used in vbmodalShell
Public Type STARTUPINFO
   cb                      As Long
   lpReserved              As String
   lpDesktop               As String
   lpTitle                 As String
   dwX                     As Long
   dwY                     As Long
   dwXSize                 As Long
   dwYSize                 As Long
   dwXCountChars           As Long
   dwYCountChars           As Long
   dwFillAttribute         As Long
   dwFlags                 As Long
   wShowWindow             As Integer
   cbReserved2             As Integer
   lpReserved2             As Long
   hStdInput               As Long
   hStdOutput              As Long
   hStdError               As Long
End Type

Public Type PROCESS_INFORMATION
   hProcess                As Long
   hThread                 As Long
   dwProcessID             As Long
   dwThreadID              As Long
End Type
    
'Base Table CT_   general Type for many Code tables
'Other can contain any appropriate string dependant on table and should be
' documented in code (client and server sides)
Type SIMPLEtype
   Rowid    As String
   Code      As String
   Descr     As String
   Other      As String
End Type
' Base Table SS_Group
Type SSGRP
    Rowid As String
    Desc As String
    FirstMenu As String
    FirstMenuType As String
End Type

' Base Table SS_GroupVBExecFunction
Type udtSSGVF
    Rowid      As String   '1
    SSVBFDR    As String   '2
    ReadOnly   As String   '3
End Type
    
'DLL Declares
Global Const WM_QUIT = &H12
Global Const WM_USER = &H400
Public Const GWW_HWNDPARENT = (-8)
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2

'
Public Const MF_BYCOMMAND = &H0
Public Const SC_SIZE = &HF000
Public Const SC_MOVE = &HF010
Public Const SC_MINIMIZE = &HF020
Public Const SC_MAXIMIZE = &HF030
Public Const SC_CLOSE = &HF060
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_SIZEBOX = &H40000
Public Const GWL_STYLE = (-16)

Public Const CB_FINDSTRINGEXACT = &H158
Public Const EM_SETTABSTOPS = &HCB
Public Const SM_CXFRAME = 32
Public Const SM_CYCAPTION = 4
Public Const SM_CYFRAME = 33
Public Const SM_CYMENU = 15

Public Const SPI_GETWORKAREA = 48
'For Combo Box Stuff
Public Const CB_GETDROPPEDCONTROLRECT = &H152
Public Const CB_SETDROPPEDWIDTH = &H160
Public Const CB_GETDROPPEDWIDTH = &H15F

'Interval (msecs) between automatic refeshes of forms
'Global Const REFRESH_INTERVAL = 10000 ' 10 secs good for testing
Global Const REFRESH_INTERVAL = 60000 ' 1 minute interval

Global Const HKEY_CLASSES_ROOT = &H80000000
Global Const HKEY_CURRENT_USER = &H80000001
Global Const HKEY_LOCAL_MACHINE = &H80000002
Global Const HKEY_USERS = &H80000003
Global Const REG_NONE As Long = 0
Global Const REG_SZ As Long = 1
Global Const REG_DWORD As Long = 4
Global Const ERROR_NONE = 0
Global Const KEY_ALL_ACCESS = &H3F
Global Const REG_OPTION_NON_VOLATILE = 0

Global Const WSI_ComputerName = 2

' Colors - copied from CONSTANT.TXT
'SP retired 'Global Const gValidFieldColor = &H0&
'SP retired 'Global Const RED = &HFF&
'SP retired 'Global Const GREEN = &HFF00&
'SP retired 'Global Const YELLOW = &HFFFF&
'SP retired 'Global Const BLUE = &HFF0000
'SP retired 'Global Const MAGENTA = &HFF00FF
'SP retired 'Global Const CYAN = &HFFFF00
'SP retired 'Global Const gMandatoryFieldNotBlankColor = &HFFFFFF
'SP retired 'Global Const DARKBLUE = &H800000
'SP retired 'Global Const GREY = &HC0C0C0
'SP retired 'Global Const DARKGREY = &H808080
'SP retired 'Global Const TEAL = &H808000
Global Const ORANGE = &H80FF&

'Global constants - Colors
'SP retired 'Global Const gMandatoryFieldBlankColor = CYAN
'SP retired 'Global Const gInValidFieldColor = RED
'SP retired 'Global Const gValidFieldColor = gValidFieldColor

'Constants For Control Setting
Global Const FLD_VALID = 0
Global Const FLD_MANDATORY = 1
Global Const FLD_INVALID = 2
Global Const FLD_UPPERCASE = 3

Global Const NORMAL_PRIORITY_CLASS = &H20&
Global Const INFINITE = -1&

Global Const GSAUTOUPGRADE = "AutoUpgrade.exe"

'Help File Constants
Global Const HELP_INDEX = 3
Global Const HELP_HELPONHELP = 4

'Direction for TableDrive.AddRow Method
Global Const TD_PREVIOUS = -1
Global Const TD_NEXT = 1
Global Const TB_REVERSE = -1
Global Const TB_FORWARD = 1

'position of data in Command line
'user param first because they are already assigned like that in too many places to change it ...
Global Const USERPARAM_POSITION = 7
Global Const EXEPARAM_POSITION = 8

'MEDTRAK Constants
Global Const MTCANCEL = 1
Global Const MTYES = 2
Global Const MTNO = 4
Global Const MTYESTOALL = 8
Global Const MTNOTOALL = 16

Global gMenuOptions As String

'Late bound activeX constants (which may be used from all systems)
Global Const X_TKLICENSE = "tkLicense.License"

Global DELIM_COM            As String
Global DELIM_REC_SEP        As String
Global DELIM_REC_SEP2       As String
Global DELIM_DBL_BAR        As String

'Used by LabTrak - Kevin

Public Enum UserAccessType
    ua_FullAccess = 0
    ua_Viewable = 1
    ua_NotViewable = 2
    ua_NoAccess = 3
End Enum

Public Function ComponentInitialise(sMenuOptions As String, Appl As Object, sCommand As String, Optional ID As String) As Boolean
    DELIM_STD = "^"
    DELIM_SYS = Chr$(1)
    DELIM_ALT = Chr$(2)
    DELIM_FTA = Chr$(20)
    DELIM_CRA = Chr$(21)
    
    DELIM_COM = Chr$(23)
    DELIM_REC_SEP = Chr$(28)
    DELIM_REC_SEP2 = Chr$(27)
    DELIM_DBL_BAR = "||"

    'Avoid creating a separate module as a holder for this function
    #If tkSystem Then
    ComponentInitialise = m_ApplicationInitialise(sMenuOptions, Appl, sCommand, ID)
    #Else
    

    ComponentInitialise = ApplicationInitialise(sMenuOptions, Appl, sCommand, ID)
    
'    ComponentInitialise = ApplicationInitialise(sMenuOptions, Appl, sCommand)
    
    #End If

End Function
Public Sub ExtendedListLoad(List As Object, udtArray() As SIMPLEtype)
   '+++ VB/Rig Skip +++
   'Loads an object of Type ExtendedList with the contents of a SimpleType
   'array. Note Extendedlist is used to conect List/ComboBoxes with
   'Code Table arrays
   Dim ErrText       As String
   Dim i             As Integer
   Dim Row(0 To 3)   As String
   
   On Error GoTo ExtendedListLoadError:
   
5500  List.clear
5510  For i = 1 To UBound(udtArray)
5520     Row(0) = udtArray(i).Rowid
5530     Row(1) = udtArray(i).Code
5540     Row(2) = udtArray(i).Descr
5550     Row(3) = udtArray(i).Other
5560     List.Add Row()
5570  Next i

Exit Sub
'=====================
ExtendedListLoadError:
'=====================

End Sub

Public Sub CrystalDateConvert(ByVal RPTCode As String, P2 As String, P3 As String, P4 As String, P5 As String, P6 As String, P7 As String, P8 As Variant, P9 As String)
Dim sDate As String

'Charlie 9.10.98
'This is a nasty hack to the release, to pass dates in a proper format for crystal to deal with.
'NOTE : ALWAYS INCREMENT P WITH 1 ie P7 in documentation = P8 here
Select Case UCase(RPTCode)
Case "ORDER02"
    'P7,P8
    P8 = ConvertDateParam(P8, "F")
    P9 = ConvertDateParam(P9, "T")
Case "ORDER04"
    'P7,P8
    P8 = ConvertDateParam(P8, "F")
    P9 = ConvertDateParam(P9, "T")
Case "EMR02"
    'P5,P6
    P6 = ConvertDateParam(P6, "F")
    P7 = ConvertDateParam(P7, "T")
Case "NRDATE1"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "NURSE01"
    'P7,P8
    P8 = ConvertDateParam(P8, "F")
    P9 = ConvertDateParam(P9, "T")
Case "NURSE02"
    'P5,P7
    P6 = ConvertDateParam(P6, "F")
    P8 = ConvertDateParam(P8, "T")
Case "NURSE03"
    'P7,P8
    P8 = ConvertDateParam(P8, "F")
    P9 = ConvertDateParam(P9, "T")
Case "DIETINQ"
    'P5
    P6 = ConvertDateParam(P6, "F")
Case "DIETTFM"
    'P5
    P6 = ConvertDateParam(P6, "F")
Case "DIETMFM"
    'P5
    P6 = ConvertDateParam(P6, "F")
Case "DIETPMSR"
    'P6
    P7 = ConvertDateParam(P7, "F")
Case "OPTHRE01"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE02"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE03"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE04"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE05"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE06"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE07"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "OPTHRE08"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "STLOCINQ7"
    'P7
    P8 = ConvertDateParam(P8, "F")
Case "APPTLIST"
    'P7
    P8 = ConvertDateParam(P8, "F")
Case "STTRANS1", "STTRANS2", "STTRANS3", "STTRANS4"
    'P5
    P6 = ConvertDateParam(P6, "F")
Case "ADMTRINQ01"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "STPUR5"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "MRO02"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "MRO03"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "MRO04"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "MRO05"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "MRO06"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "PATREG24"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "PATREG25"
    'P4,P5
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "INSBILL01"
    'P7,P8
    P8 = ConvertDateParam(P8, "F")
    P9 = ConvertDateParam(P9, "T")
Case "INSBILL03"
    'P6,P7
    P7 = ConvertDateParam(P7, "F")
    P8 = ConvertDateParam(P8, "T")
Case "INSBILL04"
    'P5,P6
    P6 = ConvertDateParam(P6, "F")
    P7 = ConvertDateParam(P7, "T")
Case "INSBILL07"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "INSBILL08"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "INSBILL09"
    'P4,P5
    P5 = ConvertDateParam(P5, "F")
    P6 = ConvertDateParam(P6, "T")
Case "INSBILL13"
    'P3,P4
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "INSBILL14"
    'P3,P4
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "INSBILL15"
    'P3,P4
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "INSBILL16"
    'P3,P4
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "INSBILL17"
    'P3,P4
    P4 = ConvertDateParam(P4, "F")
    P5 = ConvertDateParam(P5, "T")
Case "INSBILL18"
    'P3
    P4 = ConvertDateParam(P4, "F")
Case "INSBILL19"
    'P3
    P4 = ConvertDateParam(P4, "F")
End Select


End Sub
Public Function ConvertDateParam(sDate As Variant, sType As String) As String
Dim sTemp As String
'sType used to hardcode date if not entered.  Pass F if date is date From or T if date is date to.
If sDate <> "" Then
    sTemp = DatePart("yyyy", sDate)
'    If Len(sTemp) = 4 Then
'        'get yy format
'        sTemp = Right$(sTemp, 2)
'    End If
    ConvertDateParam = "date(" & sTemp
    sTemp = DatePart("m", sDate)
    ConvertDateParam = ConvertDateParam & "," & sTemp
    sTemp = DatePart("d", sDate)
    ConvertDateParam = ConvertDateParam & "," & sTemp & ")"
Else
    If sType = "F" Then
        ConvertDateParam = "Date(1850,01,01)"
    ElseIf sType = "T" Then
        ConvertDateParam = "Date(2100,01,01)"
    End If
End If
End Function
Public Function FormatDate(ByVal HDate As String, ByVal WDate As String, ByVal sFormat As String) As String
'Charlie 19/5
'For countries using same separater for date and numbers, vb's format function
'returns rubbish.  This function should overcome that.  More specifically the
'problem occurs when passing in a Windows date, but works ok for $H dates.
'Pass in Hdate if known, or windows date which is then converted to Hdate

    If WDate <> "" Then
        HDate = FormatDollarHDate(WDate)
    End If
    If HDate <> "" Then
        FormatDate = FormatGenDate(HDate, sFormat)
    End If
End Function



